package top.yuechenc.manage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import top.yuechenc.manage.entity.SpPermission;
import top.yuechenc.manage.entity.SpPermissionDto;
import top.yuechenc.manage.mapper.SpPermissionMapper;
import top.yuechenc.manage.service.PermissionService;

import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private SpPermissionMapper permissionMapper;

    @Override
    public List<SpPermission> getByParam(SpPermission permission) {
        Example example=new Example(SpPermission.class);
        Example.Criteria criteria=example.createCriteria();
        if(permission.getPsPid()!=null&&!"".equals(permission.getPsPid())) {
            criteria.andEqualTo(permission.getPsPid());
        }
        return permissionMapper.selectByExample(example);
    }

    @Override
    public List<SpPermissionDto> getByPid(String pid) {
        List<SpPermissionDto> spo= permissionMapper.selectByPid(pid);
        return spo;
    }

    @Override
    public List<SpPermissionDto> findAll() {
        return permissionMapper.selectAllOV();
    }

    @Override
    public SpPermissionDto getById(String id) {
        return permissionMapper.selectById(id);
    }
}
